// vim: ft=glsl noet ts=4 sw=4 sts=0
R"vertex(
#version 330 core
smooth out vec2 uv;
layout(location = 0) in vec2 position;

void main()
{
	gl_Position = vec4(position, 0, 1);
	uv = position*0.5 + 0.5;
}

)vertex"

, /////////////////////////////////////////////////////////////////////////

R"fragment(
#version 330 core
out vec3 color;
smooth in vec2 uv;
uniform sampler2D blur;
uniform sampler2D scene;
uniform sampler2D scatter;
uniform float exposure;
uniform float scene_alpha;
uniform float bloom_alpha;
uniform float scatter_alpha;

vec3 pixel(sampler2D s) { return texture(s, uv).rgb; }

void main()
{
	color = scene_alpha * pixel(scene);
	color += bloom_alpha * pow(pixel(blur)/1.2, vec3(1.2));		// bloom
	color += scatter_alpha * pixel(scatter);					// scatter

	// exposure control
	float e = pow(0.5, exposure*scene_alpha);
	color = pow(color/e, vec3(e));
	color = clamp(color, 0, 1);
}

)fragment"

